package com.huawei.zyb.taskManager.domain.requirement.valueobject;

import java.util.Objects;
import java.util.UUID;

/**
 * 参考文档ID值对象
 */
public class ReferenceDocumentId {
    private final String value;

    private ReferenceDocumentId(String value) {
        this.value = Objects.requireNonNull(value, "参考文档ID不能为空");
    }

    /**
     * 生成新的参考文档ID
     */
    public static ReferenceDocumentId generate() {
        return new ReferenceDocumentId(UUID.randomUUID().toString());
    }

    /**
     * 从字符串创建参考文档ID
     */
    public static ReferenceDocumentId of(String value) {
        if (value == null || value.trim().isEmpty()) {
            throw new IllegalArgumentException("参考文档ID不能为空");
        }
        return new ReferenceDocumentId(value.trim());
    }

    public String getValue() {
        return value;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null || getClass() != obj.getClass()) return false;
        ReferenceDocumentId that = (ReferenceDocumentId) obj;
        return Objects.equals(value, that.value);
    }

    @Override
    public int hashCode() {
        return Objects.hash(value);
    }

    @Override
    public String toString() {
        return value;
    }
}